package cn.zhaozhiqi.controller.app;

import cn.zhaozhiqi.remote.api.IBigDataFeignClient;
import cn.zhaozhiqi.remote.dto.DriverPointDto;
import cn.zhaozhiqi.result.JSONResult;
import cn.zhaozhiqi.service.IDriverPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
public class BigDataFeignClientImpl implements IBigDataFeignClient {

    @Autowired
    private IDriverPointService driverPointService;


    //根据订单号返回司机的实时坐标
    @Override
    public JSONResult<List<DriverPointDto>> ComputedRealMile(String orderNo) {
        //两个微服务之间的对象不同，我们要通过流来进行属性的赋值，将对象替换
        List<DriverPointDto> list = driverPointService.selectByOrderNo(orderNo)
                .stream().map(obj -> new DriverPointDto(obj.getLatitude(), obj.getLongitude()))
                .collect(Collectors.toList());
        return JSONResult.success(list);
    }
}
